<!-- 诚意金管理 -->
<template>
    <div>
        <div class="search">
            <el-form :inline="true" :model="searchData" size="mini" class="demo-form-inline">
                <el-form-item label="">
                    <el-date-picker type="date" placeholder="请选择开始时间" v-model="searchData.start_time" value-format="yyyy-MM-dd"></el-date-picker>
                </el-form-item>
                <el-form-item label="">
                    <el-date-picker type="date" placeholder="请选择结束时间" v-model="searchData.end_time" value-format="yyyy-MM-dd"></el-date-picker>
                </el-form-item>
                <el-form-item label="">
                    <el-select v-model="searchData.e_type" placeholder="请选择交易方式">
                        <el-option v-for="(item,index) in info.type" :key="index" :label="item" :value="index"></el-option>
                    </el-select>
                </el-form-item>
                <el-form-item label="">
                    <el-select v-model="searchData.e_status" placeholder="请选择交易状态">
                        <el-option v-for="(item,index) in info.status" :key="index" :label="item" :value="index"></el-option>
                    </el-select>
                </el-form-item>
                <el-form-item label="">
                    <el-select v-model="searchData.e_d_id" placeholder="请选择部门" @change="obtainUsers">
                        <!-- <el-option v-for="(item,index) in optionName" :key="index" :label="item.name" :value="item.id"></el-option> -->
                        <el-option-group v-for="group in optionName" :key="group.label" :label="group.label">
                            <el-option v-for="item in group.options" :key="item.value" :label="item.label" :value="item.value">
                            </el-option>
                        </el-option-group>
                    </el-select>
                </el-form-item>
                <el-form-item label="">
                    <el-select v-model="searchData.e_uid" placeholder="请选择员工">
                        <el-option v-for="(item,index) in userTypes" :key="index" :label="item.u_username" :value="item.u_id"></el-option>
                    </el-select>
                </el-form-item>
                <el-form-item label="关键词:">
                    <el-input v-model="searchData.keywords" placeholder="业主姓名、电话、客户姓名、电话"></el-input>
                </el-form-item>
                <el-form-item>
                    <el-button type="primary" @click="search">查询</el-button>
                    <el-button type="primary" @click="add">添加诚意金</el-button>
                </el-form-item>
            </el-form>
        </div>

        <div class='content'>
            <el-dialog title="选择" :visible.sync="chooseroom" width="60%" center>
                <!-- 查询 -->
                <div>
                    <el-form :inline="true" :model="roomsearch" size="mini" class="demo-form-inline">
                        <el-form-item label="">
                            <el-select v-model="roomsearch.trading_type" placeholder="请选择交易方式">
                                <el-option v-for="(item,index) in info.type" :key="index" :label="item" :value="index"></el-option>
                            </el-select>
                        </el-form-item>
                        <el-form-item label="">
                            <el-select v-model="roomsearch.status" placeholder="请选择交易状态">
                                <el-option v-for="(item,index) in info.status" :key="index" :label="item" :value="index"></el-option>
                            </el-select>
                        </el-form-item>
                        <el-form-item label="">
                            <el-select v-model="roomsearch.r_d_id" placeholder="请选择部门" @change="obtainusers">
                                <!-- <el-option v-for="(item,index) in optionName" :key="index" :label="item.name" :value="item.id"></el-option> -->
                                <el-option-group v-for="group in optionName" :key="group.label" :label="group.label">
                                    <el-option v-for="item in group.options" :key="item.value" :label="item.label" :value="item.value">
                                    </el-option>
                                </el-option-group>
                            </el-select>
                        </el-form-item>
                        <el-form-item label="">
                            <el-select v-model="roomsearch.source_uid" placeholder="请选择员工">
                                <el-option v-for="(item,index) in userTypes" :key="index" :label="item.u_username" :value="item.u_id"></el-option>
                            </el-select>
                        </el-form-item>
                        <el-form-item label="关键词:">
                            <el-input v-model="roomsearch.keywords" placeholder="业主姓名、电话、客户姓名、电话"></el-input>
                        </el-form-item>
                        <el-form-item>
                            <el-button type="primary" @click="searchroom">查询</el-button>
                        </el-form-item>
                    </el-form>
                </div>
                <el-table ref="multipleTable" :data="roomlist.data" tooltip-effect="dark" style="width: 100%">
                    <el-table-column align="center" prop="id" label="房源ID" width="120"></el-table-column>
                    <el-table-column align="center" prop="property_number" label="房源编号" width="120"></el-table-column>
                    <el-table-column align="center" prop="entrust_number" label="委托编号" width="120"></el-table-column>
                    <el-table-column align="center" prop="a_id" label="区县" width="120"></el-table-column>
                    <el-table-column align="center" prop="trading_type" label="交易类型" width="120"></el-table-column>
                    <el-table-column align="center" prop="building_id" label="楼盘字典" width="120"></el-table-column>
                    <el-table-column align="center" prop="room_number" label="房号" width="120"></el-table-column>
                    <el-table-column align="center" prop="few_building" label="栋座信息" width="120"></el-table-column>
                    <el-table-column align="center" prop="r_acreage" label="房屋面积" width="120"></el-table-column>
                    <el-table-column align="center" prop="status" label="房源状态" width="120"></el-table-column>
                    <el-table-column align="center" prop="r_entrust_at" label="委托时间" width="120"></el-table-column>
                    <el-table-column align="center" fixed="right" label="操作" width="120">
                        <template slot-scope="scope">
                            <el-button @click.native.prevent="choosed(scope.row)" type="text" size="small">选择</el-button>
                        </template>
                    </el-table-column>
                </el-table>
                <!-- 分页 -->
                <el-pagination :current-page="roomcurrent" @current-change="roomcurrentChange" :total="roomlist.total" style="margin-top:30px;"></el-pagination>

            </el-dialog>
            <el-dialog :title="dialogtitle" :visible.sync="centerDialogVisible" width="60%" center>
                <el-form :model="form" :rules="rules" ref="form" label-width="120px" class="demo-ruleForm" inline size="mini">
                    <el-form-item label="房源编号" prop="e_r_num">
                        <el-input v-model="form.e_r_num" placeholder="请输入"></el-input>
                    </el-form-item>
                    <el-form-item label="交易方式" prop="e_type">
                        <el-select v-model="form.e_type" placeholder="请选择交易方式">
                            <el-option v-for="(item,index) in info.type" :key="index" :label="item" :value="index"></el-option>
                        </el-select>
                    </el-form-item>
                    <el-form-item label="意向价格" prop="e_intentional_money">
                        <el-input type="number" v-model="form.e_intentional_money" placeholder="请输入"></el-input>
                    </el-form-item>
                    <el-form-item label="用途" prop="e_use_id">
                        <el-select v-model="form.e_use_id" placeholder="请选择用途">
                            <el-option v-for="(item,index) in info.use" :key="index" :label="item.st_name" :value="item.st_id"></el-option>
                        </el-select>
                    </el-form-item>
                    <el-form-item label="房源地址" prop="e_r_address">
                        <el-input v-model="form.e_r_address" placeholder="请输入">
                            <el-button slot="append" @click="chooseroomlist">查看</el-button>
                        </el-input>
                    </el-form-item>
                    <el-form-item label="状态" prop="e_status">
                        <el-select v-model="form.e_status" placeholder="请选择状态">
                            <el-option v-for="(item,index) in info.status" :key="index" :label="item" :value="index"></el-option>
                        </el-select>
                    </el-form-item>
                    <el-form-item label="业主" prop="e_owner_name">
                        <el-input v-model="form.e_owner_name" placeholder="请输入"></el-input>
                    </el-form-item>
                    <el-form-item label="业主手机号" prop="e_owner_phone">
                        <el-input v-model="form.e_owner_phone" placeholder="请输入"></el-input>
                    </el-form-item>
                    <el-form-item label="业主座机" prop="e_owner_tel">
                        <el-input v-model="form.e_owner_tel" placeholder="请输入"></el-input>
                    </el-form-item>
                    <el-form-item label="业主地址" prop="e_owner_address">
                        <el-input v-model="form.e_owner_address" placeholder="请输入"></el-input>
                    </el-form-item>
                    <el-form-item label="业主身份证号" prop="e_owner_idnum">
                        <el-input v-model="form.e_owner_idnum" placeholder="请输入"></el-input>
                    </el-form-item>
                    <el-form-item label="客户" prop="e_customer_name">
                        <el-input v-model="form.e_customer_name" placeholder="请输入"></el-input>
                    </el-form-item>
                    <el-form-item label="客户手机号" prop="e_customer_phone">
                        <el-input v-model="form.e_customer_phone" placeholder="请输入"></el-input>
                    </el-form-item>
                    <el-form-item label="客户座机" prop="e_customer_tel">
                        <el-input v-model="form.e_customer_tel" placeholder="请输入"></el-input>
                    </el-form-item>
                    <el-form-item label="客户地址" prop="e_customer_address">
                        <el-input v-model="form.e_customer_address" placeholder="请输入"></el-input>
                    </el-form-item>
                    <el-form-item label="客户身份证号" prop="e_customer_idnum">
                        <el-input v-model="form.e_customer_idnum" placeholder="请输入"></el-input>
                    </el-form-item>
                    <el-form-item label="诚意金额" prop="e_price">
                        <el-input type="number" v-model="form.e_price" placeholder="请输入"></el-input>
                    </el-form-item>
                    <el-form-item label="收款日期" prop="e_date">
                        <el-date-picker type="date" placeholder="请选择" v-model="form.e_date" value-format="yyyy-MM-dd"></el-date-picker>
                    </el-form-item>
                    <el-form-item label="收款编号" prop="e_receipt_num">
                        <el-input v-model="form.e_receipt_num" placeholder="请输入"></el-input>
                    </el-form-item>
                    <el-form-item label="收款方式" prop="e_pay_type">
                        <el-select v-model="form.e_pay_type" placeholder="请选择收款方式">
                            <el-option v-for="(item,index) in info.pay_type" :key="index" :label="item" :value="index"></el-option>
                        </el-select>
                    </el-form-item>
                    <el-form-item label="部门" prop="e_d_id">
                        <el-select v-model="form.e_d_id" placeholder="请选择部门" @change="obtainUser">
                            <!-- <el-option v-for="(item,index) in optionName" :key="index" :label="item.name" :value="item.id"></el-option> -->
                            <el-option-group v-for="group in optionName" :key="group.label" :label="group.label">
                                <el-option v-for="item in group.options" :key="item.value" :label="item.label" :value="item.value">
                                </el-option>
                            </el-option-group>
                        </el-select>
                    </el-form-item>
                    <el-form-item label="员工" prop="e_uid">
                        <el-select v-model="form.e_uid" placeholder="请选择员工">
                            <el-option v-for="(item,index) in userType" :key="index" :label="item.u_username" :value="item.u_id"></el-option>
                        </el-select>
                    </el-form-item>
                    <el-form-item label="退款备注" prop="e_refund">
                        <el-input type="textarea" v-model="form.e_refund" placeholder="请输入"></el-input>
                    </el-form-item>
                    <el-form-item label="备注" prop="e_remark">
                        <el-input type="textarea" v-model="form.e_remark" placeholder="请输入"></el-input>
                    </el-form-item>
                </el-form>
                <span slot="footer" class="dialog-footer">
                    <el-button @click="cancel('form')" size="mini">取 消</el-button>
                    <el-button type="primary" @click="submit('form')" size="mini">确 定</el-button>
                </span>
            </el-dialog>
            <div class='list'>
                <el-table ref="multipleTable" :data="list.data" tooltip-effect="light" style="width: 100%">
                    <el-table-column align="center" prop="e_r_num" label="房源编号" width="120"></el-table-column>
                    <el-table-column align="center" prop="e_type_name" label="交易类型" width="120"></el-table-column>
                    <el-table-column align="center" prop="e_intentional_money" label="意向价格" width="120"></el-table-column>
                    <el-table-column align="center" prop="e_use_name" label="用途" width="120"></el-table-column>
                    <el-table-column align="center" prop="e_r_address" label="房源地址" width="120" show-overflow-tooltip></el-table-column>
                    <el-table-column align="center" prop="e_status_name" label="状态" width="120"></el-table-column>
                    <el-table-column align="center" prop="e_owner_name" label="业主" width="120"></el-table-column>
                    <el-table-column align="center" prop="e_owner_phone" label="业主手机号" width="120"></el-table-column>
                    <el-table-column align="center" prop="e_owner_address" label="业主地址" width="120" show-overflow-tooltip></el-table-column>
                    <el-table-column align="center" prop="e_customer_name" label="客户" width="120"></el-table-column>
                    <el-table-column align="center" prop="e_customer_phone" label="客户手机号" width="120"></el-table-column>
                    <el-table-column align="center" prop="e_customer_address" label="客户地址" width="120" show-overflow-tooltip></el-table-column>
                    <el-table-column align="center" prop="e_receipt_num" label="收据编号" width="120"></el-table-column>
                    <el-table-column align="center" prop="e_pay_name" label="付款方式" width="120"></el-table-column>
                    <el-table-column align="center" prop="name" label="部门" width="120"></el-table-column>
                    <el-table-column align="center" prop="u_username" label="员工" width="120"></el-table-column>
                    <el-table-column align="center" prop="e_refund" label="退款备注" width="120" show-overflow-tooltip></el-table-column>
                    <el-table-column align="center" prop="e_remark" label="备注" width="120" show-overflow-tooltip></el-table-column>
                    <el-table-column align="center" fixed="right" label="操作" width="120">
                    <template slot-scope="scope">
                        <el-button @click.native.prevent="edit(scope.row)" type="text" size="small">编辑</el-button>
                        <el-button @click.native.prevent="del(scope.row)" type="text" size="small">删除</el-button>
                    </template>
                    </el-table-column>
                </el-table>
                <!-- 分页 -->
                <el-pagination :current-page="current" @current-change="handleCurrentChange" :total="list.total" style="margin-top:30px;"></el-pagination>
            </div>
        </div>
    </div>
</template>
<style>
    .home .view-content{
        width: 87%;
    }
    .el-form-item__label,.el-form-item__content{
        font-size: 12px;
    }
    .el-input{
        padding-right: 5px;
    }
    .el-select-dropdown__item{
        font-size: 12px;
        padding: 0px 10px;
        height: 26px;
        line-height: 26px;
    }
    .el-input,.el-date-editor.el-input{
        width: 145px;
    }
</style>
<script>
    import conf from '../../config/userconf.js'
    import permconfig from '../../config/permconfig.js'
    export default {
        data() {
            var validatePhone = (rule,value,callback) => {    //正则手机号

                var MobileRegex = /^1[3|4|5|7|8][0-9]{9}$/;
                if (!MobileRegex.test(value)) {
                    callback(new Error('手机号格式不正确！'))
                } else {
                    callback();
                }
            };
            return {
                list: [],  //  
                roomlist: [],
                searchData:{
                    start_time: '',
                    end_time: '',
                    e_type: '',
                    e_status: '',
                    e_d_id: '',
                    e_uid: '',
                    keywords: '',
                },
                roomsearch:{
                    r_d_id: '',
                    source_uid: '',
                    keywords: '',
                    trading_type: '',
                    status: '',
                },
                form: {
                    e_r_num: '',
                    e_type: '',
                    e_intentional_money: '',
                    e_use_id: '',
                    e_r_address: '',
                    e_status: '',
                    e_owner_name: '',
                    e_owner_phone: '',
                    e_owner_tel: '',
                    e_owner_address: '',
                    e_owner_idnum: '',
                    e_customer_name: '',
                    e_customer_phone: '',
                    e_customer_tel: '',
                    e_customer_address: '',
                    e_customer_idnum: '',
                    e_price: '',
                    e_date: '',
                    e_receipt_num: '',
                    e_pay_type: '',
                    e_d_id: '',
                    e_uid: '',
                    e_refund: '',
                    e_remark: '',
                },
                rules: {
                    e_r_num: [
                        { required: true, message: '请输入房源编号', trigger: 'blur' }
                    ],
                    e_type: [
                        { required: true, message: '请选择交易方式', trigger: 'change' }
                    ],
                    e_intentional_money: [
                        { required: true, message: '请输入意向价格', trigger: 'blur' }
                    ],
                    e_use_id: [
                        { required: true, message: '请选择用途', trigger: 'change' }
                    ],
                    e_r_address: [
                        { required: true, message: '请选择房源地址', trigger: 'change' }
                    ],
                    e_status: [
                        { required: true, message: '请选择状态', trigger: 'change' }
                    ],
                    e_owner_name: [
                        { required: true, message: '请输入业主名称', trigger: 'blur' }
                    ],
                    e_owner_phone: [
                        { required: true, message: '请输入业主手机号', trigger: 'blur' },
                        { validator: validatePhone, trigger: 'blur'}
                    ],
                    e_owner_address: [
                        { required: true, message: '请输入业主地址', trigger: 'blur' }
                    ],
                    e_customer_name: [
                        { required: true, message: '请输入客户名称', trigger: 'blur' }
                    ],
                    e_customer_phone: [
                        { required: true, message: '请输入客户手机号', trigger: 'blur' },
                        { validator: validatePhone, trigger: 'blur'}
                    ],
                    e_customer_address: [
                        { required: true, message: '请输入客户地址', trigger: 'blur' }
                    ],
                    e_receipt_num: [
                        { required: true, message: '请输入收据编号', trigger: 'blur' }
                    ],
                    e_pay_type: [
                        { required: true, message: '请选择付款方式', trigger: 'change' }
                    ],
                    e_d_id: [
                        { required: true, message: '请选择部门', trigger: 'change' }
                    ],
                    e_uid: [
                        { required: true, message: '请选择员工', trigger: 'change' }
                    ],
                },
                current: 1, 
                roomcurrent: 1,  
                optionName: [],
                userType: [],  
                userTypes: [],
                usertypes: [],
                dialogtitle: '添加诚意金',
                centerDialogVisible: false,   
                chooseroom: false,
                info: {},
                e_id: '',
            }
        },
        methods: {
            /* 列表*/
            getList (data=Object()){
                data.page = this.current;
                conf.earnestmoney.list(data,(state,res)=>{
                    if (state == 'success'&&res.data.code == 0){
                        // console.log(res);
                        this.list = res.data.data;
                    }else if(state == 'success'&&res.data.code != 0){
                        if(res.data.code == -404){
                            this.list = [];
                        }else{
                            this.$message({
                                type: 'info',
                                message: res.data.msg
                            });
                        }
                        
                    }
                })
            },
            /* 下拉选项*/
            infos (data=Object()){
                conf.earnestmoney.datalist(data,(state,res)=>{
                    if (state == 'success'&&res.data.code == 0){
                        // console.log(res);
                        this.info = res.data.data;
                    }else if(state == 'success'&&res.data.code != 0){
                        if(res.data.code == 401){
                            this.$router.push({name:'login'});   //登陆态失效，跳转至登录页
                        }else{
                            this.$message({
                                type: 'info',
                                message: res.data.msg
                            });
                        }
                    }
                })
            },
            /* 简易房源列表*/
            roomList (data=Object()){
                data.page = this.roomcurrent;
                conf.room.easylist(data,(state,res)=>{
                    if (state == 'success'&&res.data.code == 0){
                        // console.log(res);
                        this.roomlist = res.data.data;
                    }else if(state == 'success'&&res.data.code != 0){
                        if(res.data.code == 401){
                            this.$router.push({name:'login'});   //登陆态失效，跳转至登录页
                        }else if(res.data.code == -404){
                            this.roomlist = [];
                        }else{
                            this.$message({
                                type: 'info',
                                message: res.data.msg
                            });
                        }
                    }
                })
            },
            //选择房源
            choosed(row){
                console.log(row);
                this.form.e_r_num = row.property_number;
                this.form.e_r_address = row.building_id + row.few_building + row.room_number;
                this.chooseroom = false;
            },
            /*查询 */
            search () {
                let data  = this.searchData;
                this.getList(data);
            },
            searchroom(){
                let data  = this.roomsearch;
                this.roomList(data);
            },
            /*取消 */
            cancel (formName) {
                this.centerDialogVisible = false;
                this.$refs[formName].resetFields();
            },
            /*提交 */
            submit (formName) {
                console.log(formName);
                this.$refs[formName].validate((valid) => {
                    if (valid) {
                        this.judgeprimise();
                    } else {
                        console.log('error submit!!');
                        return false;
                    }
                });
            },
            /*判断提交 */
            judgeprimise (data=null) {
                if (this.dialogtitle == '添加诚意金') {
                    conf.earnestmoney.add(this.form,(state,res)=>{
                        if (state == 'success'&&res.data.code == 0){
                            this.search();
                            this.centerDialogVisible = false;
                            this.$message({
                                type: 'success',
                                message: '添加成功!'
                            });
                        }else if(state == 'success'&&res.data.code != 0){
                            if(res.data.code == 401){
                                this.$router.push({name:'login'});   //登陆态失效，跳转至登录页
                            }else{
                                this.$message({
                                    type: 'info',
                                    message: res.data.msg
                                });
                            }
                        }
                    })
                }else if (this.dialogtitle == '修改诚意金信息'){
                    data = this.form;
                    data.e_id = this.e_id;
                    conf.earnestmoney.edit(data,(state,res)=>{
                        if (state == 'success'&&res.data.code == 0){
                            this.search();
                            this.centerDialogVisible = false;
                            this.$message({
                                type: 'success',
                                message: '修改成功!'
                            });
                        }else if(state == 'success'&&res.data.code != 0){
                            if(res.data.code == 401){
                                this.$router.push({name:'login'});   //登陆态失效，跳转至登录页
                            }else{
                                this.$message({
                                    type: 'info',
                                    message: res.data.msg
                                });
                            }
                        }
                    })
                }
            },
            /*增 */
            add (formName) {
                var ownerPermission = window.localStorage.getItem('authories');
                var arr = ownerPermission.split(',');
                if(arr.indexOf(permconfig.qx_qita_tianjiachengyijin)  == -1){
                    alert('您没有该功能的权限');
                    return;
                }

                this.dialogtitle = '添加诚意金';
                this.centerDialogVisible = true;
            },
            // 删除部门
            del(row,data=Object()) {
                var ownerPermission = window.localStorage.getItem('authories');
                var arr = ownerPermission.split(',');
                if(arr.indexOf(permconfig.qx_qita_shanchuchengyijin)  == -1){
                    alert('您没有该功能的权限');
                    return;
                }
                // console.log(row);
                this.$confirm('确认删除房源编号 "'+row.e_r_num+'" ?', '删除诚意金', {  
                    confirmButtonText: '确定',
                    cancelButtonText: '取消',
                    type: 'warning'
                }).then(() => {

                    data.e_id = row.e_id;
                    conf.earnestmoney.del(data,(state,res)=>{
                        if (state == 'success'&&res.data.code == 0){
                            this.getList();
                            this.$message({
                                type: 'success',
                                message: '删除成功!'
                            });
                        }else if(state == 'success'&&res.data.code != 0){
                            if(res.data.code == 401){
                                this.$router.push({name:'login'});   //登陆态失效，跳转至登录页
                            }else{
                                this.$message({
                                    type: 'info',
                                    message: res.data.msg
                                });
                            }
                        }
                    })

                }).catch(() => {
                    this.$message({
                    type: 'info',
                    message: '已取消删除'
                    });          
                });
            },
            /**改*/
            edit (val) {
                var ownerPermission = window.localStorage.getItem('authories');
                var arr = ownerPermission.split(',');
                if(arr.indexOf(permconfig.qx_qita_xiugaichengyijin)  == -1){
                    alert('您没有该功能的权限');
                    return;
                }
                this.dialogtitle = '修改诚意金信息';
                this.form = {
                    e_r_num: val.e_r_num,
                    e_type: val.e_type,
                    e_intentional_money: val.e_intentional_money,
                    e_use_id: val.e_use_id,
                    e_r_address: val.e_r_address,
                    e_status: val.e_status,
                    e_owner_name: val.e_owner_name,
                    e_owner_phone: val.e_owner_phone,
                    e_owner_tel: val.e_owner_tel,
                    e_owner_address: val.e_owner_address,
                    e_owner_idnum: val.e_owner_idnum,
                    e_customer_name: val.e_customer_name,
                    e_customer_phone: val.e_customer_phone,
                    e_customer_tel: val.e_customer_tel,
                    e_customer_address: val.e_customer_address,
                    e_customer_idnum: val.e_customer_idnum,
                    e_price: val.e_price,
                    e_date: val.e_date,
                    e_receipt_num: val.e_receipt_num,
                    e_pay_type: val.e_pay_type,
                    e_d_id: val.e_d_id,
                    e_uid: val.e_uid,
                    e_refund: val.e_refund,
                    e_remark: val.e_remark,
                };
                this.e_id = val.e_id;
                this.centerDialogVisible = true;
            },
            //选择房源列表
            chooseroomlist(){
                this.roomsearch.r_d_id = parseInt(window.localStorage.getItem('did'));
                this.roomsearch.source_uid = parseInt(window.localStorage.getItem('uid'));

                this.chooseroom = true;
            },
            // 切换页码
            handleCurrentChange(val) {
                this.current = val;
                this.getList();
            },
            //简易房源列表  切换页码
            roomcurrentChange(val) {
                this.roomcurrent = val;
                this.roomList();
            },
            //获取部门
            obtainName(data=Object()){
                conf.department.nameOpt(data,(state,res)=>{
                    if (state == 'success'&&res.data.code == 0){
                        this.optionName = res.data.data;
                        // console.log(res); 
                    }else if(state == 'success'&&res.data.code != 0){
                        if(res.data.code == 401){
                            this.$router.push({name:'login'});   //登陆态失效，跳转至登录页
                        }else if(res.data.code == -404){
                            this.optionName = [];
                        }else{
                            this.$message({
                                type: 'info',
                                message: res.data.msg
                            });
                        }
                    }
                })
            },
            //获取部门员工
            obtainUser(val,data=Object()){
                this.userType = [];
                this.form.e_uid = '';
                data.d_id = val;
                conf.department.userOpt(data,(state,res)=>{
                    if (state == 'success'&&res.data.code == 0){
                        // console.log(res); 
                        this.userType = res.data.data;
                    }else if(state == 'success'&&res.data.code != 0){
                        this.$message({
                            type: 'info',
                            message: res.data.msg
                        });
                    }
                })
            },
            //获取部门员工  (搜索)
            obtainUsers(val,data=Object()){
                this.userTypes = [];
                this.searchData.e_uid = '';
                data.d_id = val;
                conf.department.userOpt(data,(state,res)=>{
                    if (state == 'success'&&res.data.code == 0){
                        // console.log(res); 
                        this.userTypes = res.data.data;
                    }else if(state == 'success'&&res.data.code != 0){
                        if(res.data.code == 401){
                            this.$router.push({name:'login'});   //登陆态失效，跳转至登录页
                        }else{
                            this.$message({
                                type: 'info',
                                message: res.data.msg
                            });
                        }
                    }
                })
            },
            //获取部门员工  (房源列表搜索)
            obtainusers(val,data=Object()){
                this.usertypes = [];
                this.roomsearch.e_uid = '';
                data.d_id = val;
                conf.department.userOpt(data,(state,res)=>{
                    if (state == 'success'&&res.data.code == 0){
                        // console.log(res); 
                        this.usertypes = res.data.data;
                    }else if(state == 'success'&&res.data.code != 0){
                        if(res.data.code == 401){
                            this.$router.push({name:'login'});   //登陆态失效，跳转至登录页
                        }else{
                            this.$message({
                                type: 'info',
                                message: res.data.msg
                            });
                        }
                    }
                })
            },
        },
        mounted (){
            this.$nextTick(function(){
                this.infos();
                this.getList();
                this.obtainName();
                this.obtainUsers();
                this.roomList();
                this.obtainusers();
            })
        },
    }
</script>